/*
 * Copyright (c) 2016, www.zm0618.com All Rights Reserved..
 */

package com.ibetter.mr.parse.comment;

import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * Created by zhaojun on 2016/12/10.
 */
public class UserCommentMapper extends Mapper<LongWritable,Text,LongWritable,LongWritable>{

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        if (value!=null){
                String valStr=value.toString();
                if (StringUtils.isNotBlank(valStr)){
                    String[] commentFields = valStr.split(",");
                    LongWritable  doctorId=new LongWritable(Long.parseLong(StringUtils.trim(commentFields[5])));
                    LongWritable  infoId=new LongWritable(Long.parseLong(StringUtils.trim(commentFields[1])));
                    context.write(doctorId,infoId);
                }

        }
    }
}
